import '../interfaces/i_user.dart';

mixin UserMixin implements IUser {
  @override
  late final String id;
  @override
  late final String name;
  @override
  late final String email;

  void validateEmail(String email) {
    if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(email)) {
      throw ArgumentError('Invalid email format');
    }
  }

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'email': email,
    };
  }
}